package im.vinci.server.discovery.service;

import im.vinci.server.common.exceptions.VinciException;
import im.vinci.server.discovery.domain.Music;
import im.vinci.server.discovery.domain.wrappers.DiscoveryResponse;
import im.vinci.server.discovery.persistence.DiscoveryMapper;
import im.vinci.server.utils.BizTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by mingjie on 16/10/26.
 */
@Service
public class DiscoveryService {

    @Autowired
    private DiscoveryMapper discoveryMapper;

    public DiscoveryResponse showHomePage() {
        return new BizTemplate<DiscoveryResponse>(getClass().getSimpleName() + ".showHomePage") {
            @Override
            protected void checkParams() throws VinciException {

            }

            @Override
            protected DiscoveryResponse process() throws Exception {
                return discoveryMapper.showHomePage();
            }
        }.execute();
    }

    public List<Music> getMusicList(long musicListId) {
        return new BizTemplate<List<Music>>(getClass().getSimpleName() + ".getMusicList") {
            @Override
            protected void checkParams() throws VinciException {

            }

            @Override
            protected List<Music> process() throws Exception {
                return discoveryMapper.getMusicList(musicListId);
            }
        }.execute();
    }

}
